class KnowledgeTreeData {
  List<KnowledgeTreeItem?>? data;

  KnowledgeTreeData.fromJson(dynamic json) {
    if(json is List) {
      data = [];
      for (var item in json) {
        data?.add(KnowledgeTreeItem.fromJson(item));
      }
    }
  }
}

class KnowledgeTreeItem {
  List<dynamic> articleList;
  String author;
  List<Children> children;
  int courseId;
  String cover;
  String desc;
  int id;
  String lisense;
  String lisenseLink;
  String name;
  int order;
  int parentChapterId;
  int type;
  bool userControlSetTop;
  int visible;

  KnowledgeTreeItem({
    required this.articleList,
    required this.author,
    required this.children,
    required this.courseId,
    required this.cover,
    required this.desc,
    required this.id,
    required this.lisense,
    required this.lisenseLink,
    required this.name,
    required this.order,
    required this.parentChapterId,
    required this.type,
    required this.userControlSetTop,
    required this.visible,
  });

  factory KnowledgeTreeItem.fromJson(Map<String, dynamic> json) {
    return KnowledgeTreeItem(
      articleList: json['articleList'],
      author: json['author'],
      children: (json['children'] as List).map((e) => Children.fromJson(e)).toList(),
      courseId: json['courseId'],
      cover: json['cover'],
      desc: json['desc'],
      id: json['id'],
      lisense: json['lisense'],
      lisenseLink: json['lisenseLink'],
      name: json['name'],
      order: json['order'],
      parentChapterId: json['parentChapterId'],
      type: json['type'],
      userControlSetTop: json['userControlSetTop'],
      visible: json['visible'],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'articleList': articleList,
      'author': author,
      'children': children.map((e) => e.toJson()).toList(),
      'courseId': courseId,
      'cover': cover,
      'desc': desc,
      'id': id,
      'lisense': lisense,
      'lisenseLink': lisenseLink,
      'name': name,
      'order': order,
      'parentChapterId': parentChapterId,
      'type': type,
      'userControlSetTop': userControlSetTop,
      'visible': visible,
    };
  }
}

class Children {
  List<dynamic> articleList;
  String author;
  List<dynamic> children;
  int courseId;
  String cover;
  String desc;
  int id;
  String lisense;
  String lisenseLink;
  String name;
  int order;
  int parentChapterId;
  int type;
  bool userControlSetTop;
  int visible;

  Children({
    required this.articleList,
    required this.author,
    required this.children,
    required this.courseId,
    required this.cover,
    required this.desc,
    required this.id,
    required this.lisense,
    required this.lisenseLink,
    required this.name,
    required this.order,
    required this.parentChapterId,
    required this.type,
    required this.userControlSetTop,
    required this.visible,
  });

  factory Children.fromJson(Map<String, dynamic> json) {
    return Children(
      articleList: json['articleList'],
      author: json['author'],
      children: json['children'],
      courseId: json['courseId'],
      cover: json['cover'],
      desc: json['desc'],
      id: json['id'],
      lisense: json['lisense'],
      lisenseLink: json['lisenseLink'],
      name: json['name'],
      order: json['order'],
      parentChapterId: json['parentChapterId'],
      type: json['type'],
      userControlSetTop: json['userControlSetTop'],
      visible: json['visible'],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'articleList': articleList,
      'author': author,
      'children': children,
      'courseId': courseId,
      'cover': cover,
      'desc': desc,
      'id': id,
      'lisense': lisense,
      'lisenseLink': lisenseLink,
      'name': name,
      'order': order,
      'parentChapterId': parentChapterId,
      'type': type,
      'userControlSetTop': userControlSetTop,
      'visible': visible,
    };
  }
}
